<?php

namespace Home\Controller;

class SousuoController extends AdminController
{
	public function index(){
		$title=$_POST['title'];
		$map['title']=array('like',"%$title%");		
		$list=M('Book')->where($map)->select();
		$arr = array(); //声明一个空数组
		foreach ($list as $v1) {
			$user = M('User')->where(array('id'=>array('eq',$v1['uid'])))->select();
			// var_dump($user);exit;
			$users = array();
			foreach($user as $v2){
				$users[] =  $v2;			
			}
			$type=M('Type')->where(array('id'=>array('eq',$v1['typeid'])))->select();
			$types=array();
			foreach ($type as $v3) {
				$types[] = $v3;
			}

			$v1['user'] = $users;
			$v1['type'] = $types; //将新得到角色信息放置到$v中
			$arr[] = $v1;
		}
		
		// var_dump($arr);exit;
		$this->assign('list',$arr);
		$this->assign('title','乐阅网');
		$this->display();
		
	}


}
